package com.cskaoyan.shopping.service.impl;

import com.cskaoyan.shopping.converter.ContentConverter;
import com.cskaoyan.shopping.dal.entitys.ItemCat;
import com.cskaoyan.shopping.dal.entitys.PanelContent;
import com.cskaoyan.shopping.dal.persistence.ItemCatMapper;
import com.cskaoyan.shopping.dal.persistence.PanelContentMapper;
import com.cskaoyan.shopping.dto.PanelContentDto;
import com.cskaoyan.shopping.service.INavigationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;

import java.util.List;
import java.util.stream.Collectors;

/**
 *
 * @since 2023/01/10 11:06
 * @author 2731235517@qq.com 谢畅
 */
@Service
@Transactional
@Slf4j
public class NavigationServiceImpl implements INavigationService {
    @Autowired
    PanelContentMapper panelContentMapper;

    @Autowired
    ContentConverter contentConverter;

    @Override
    public List<PanelContentDto> listNavigation() {
        Example example = new Example(PanelContent.class);
        example.createCriteria().andEqualTo("panelId",0);
        List<PanelContent> panelContents = panelContentMapper.selectByExample(example);

        List<PanelContentDto> panelContentDtoList = contentConverter.panelContents2Dto(panelContents);
        return panelContentDtoList;
    }
}
